// 实现图像的16级伪彩色处理
module falsecolor_proc(
	input                   clk,
	input                   rst_n,
	input                   proc_en,
	//sink 
	input           		sink_sop,
	input           		sink_eop,
	input           		sink_valid,
	input 	[7:0]			sink_data,			//原始8位灰度数据
	//source
	output         			source_sop,
	output          		source_eop,
	output          		source_valid,
	output   [23:0] 	    source_data			//16位伪彩色数据
);
reg sink_sop_r,sink_eop_r,sink_valid_r;
reg [7:0] sink_data_r;
wire [23:0] pcolor_w;
assign source_data   = proc_en?pcolor_w:{3{sink_data_r}};
//   伪彩色算法处理
pseudo_color_rom u_pseudo_color_rom_0 (
	.address(sink_data),
	.clock  (clk),
	.q      (pcolor_w)
	);

assign	source_sop  = sink_sop_r;
assign	source_valid= sink_valid_r;
assign	source_eop  = sink_eop_r;
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
    begin 
    sink_sop_r   <= 1'b0;
    sink_eop_r   <= 1'b0;  
    sink_valid_r <= 1'b0;
    sink_data_r  <= 8'd0;	
    end
else
    begin
    sink_sop_r   <= sink_sop  ;
	sink_eop_r   <= sink_eop  ;
	sink_valid_r <= sink_valid;
	sink_data_r  <= sink_data ;
    end
end

endmodule